<template>
          <div class="g-bg clearfix">
               <div class="g-mn">
                    <div class="g-mnc">
                        <div class="g-wrap6">
                             <div class="m-info clearfix">
                                 <div class="cover">
                                     <img :src="resource.album.artist.img1v1Url + '?param=177y177'" >
                                     <span class="msk"></span>
                                 </div>
                                 <div class="cnt">
                                     <div class="cntc">
                                         <div class="topblk">
                                             <div class="hd clearfix">
                                                 <i class="ab"></i>
                                                 <div class="tit">
                                                     <h2 class="f-ff2">{{resource.album.name}}</h2>
                                                 </div>
                                             </div>
                                             <p class="intr">
                                                 <b>歌手：</b>  
                                                 <span>
                                                     <a href="javascript:;" class="s-fc7 int" v-for="(el,index) in resource.album.artists" :key="index">{{el.name}}</a>
                                                    
                                                 </span>
                                  
                                             </p>
                                             <p class="intr">
                                                 <b>发行时间：</b>{{resource.album.publishTime | t}}
                                                 
                                             </p>
                                             <p class="intr">
                                                 <b>发行公司：</b>
                                                 {{resource.album.company}}
                                             </p>
                                              
                                         </div>
                                          <PageFns :sub='m_data' :mdata='song'/>
                                     </div>
                                 </div>
                             </div>
                             <div class="n-albdesc">
                                 <h3>专辑介绍：</h3>
                                 <div class="f-brk" v-show="!stretch_flag">
                                     <p>{{introduce}}</p>
                                 </div>
                                 <div v-show="stretch_flag">
                                      <p v-for="(el,index) in alliIn" :key="index">{{el}}</p>
                                 </div>
                                 <div class="f-cb clearfix">
                                      <a href="javascript:;" class="s-fc7 f-fr" @mousedown="stretch">{{stretch_flag?txt[1]:txt[0]}}<i class="u-icn u-icn-7" :class="stretch_flag?'u-icn-6':'u-icn-7'"></i></a>
                                 </div>
                             </div>
                            <div class="n-songtb ">
                                <div class="u-title-1 clearfix">
                                    <h3>
                                        <span class="f-ff2">包含歌曲列表</span>
                                       
                                    </h3>
                                     <span class="sub s-fc3">12首歌</span>
                                </div>
                                 <table class="m-table clearfix">
                                     <thead>
                                         <tr>
                                             <th class="w1">
                                                 <div class="wp">&nbsp;</div>
                                             </th>
                                             <th>
                                                 <div class="wp">歌曲标题</div>
                                             </th>
                                             <th class="w2">
                                                 <div class="wp">时长</div>
                                             </th>
                                             <th class="w3">
                                                 <div class="wp">歌手</div>
                                             </th>
                                         </tr>
                                     </thead>
                                     <tbody @mouseleave="f_show(-1)">
                                         <tr v-for="(el,index) in song" :key="el.id" @mouseenter="f_show(index)">
                                             <td class="left">
                                                 <div class="hd1">
                                                     <span class="ply" title="播放" @mousedown="play1(index)"></span>
                                               <span class="num">{{index + 1}}</span>
                                                 </div>
                                             </td>
                                              
                                               <td>
                                                   <div class="clearfix">
                                                     <div class="tt">
                                                         <div class="ttc">
                                                             <span class="txt overtext">
                                                               
                                                                 <router-link :to="{
                                                                     path:'/song',
                                                                     query:{
                                                                         id:el.id
                                                                     } 
                                                                 }">    <b>{{el.name}}</b></router-link>
                                                                 <span class="mv" title="播放MV" v-if="el.mv"></span>
                                                             </span>
                                                         </div>
                                                     </div>
                                                   </div>
                                               </td>
                                             <td class="s-fc3">
                                                 <span class="u-dur" v-show="index != flag_num">{{el.dt | formatTime}}</span>
                                                 <div class="opt" v-show="index == flag_num"><Fns :song='song[index]'/></div>
                                                 
                                             </td>
                                             <td>
                                                 <div class="text overtext">
                                                     <span>
                                                         <a href="javascirpt:;" :title="el.ar[0].name">
                                                             {{el.ar[0].name}}
                                                         </a>
                                                         <!-- <span class="s-fc8" v-if="el.ar[0].tns[0].length" :title="el.ar[0].tns[0]"> - ({{el.ar[0].tns[0]}})</span> -->
                                                     </span>
                                                 </div>
                                             </td>
                                         </tr>
                                     </tbody>
                                 </table>
                            </div>
                            <CommentArea/>
                           
                        </div>
                    </div>
               </div>
               <div class="g-sd">
                    <div class="g-wrap1">
                        <h3 class="u-hd3">
                            <span class="f-f1">喜欢这张专辑的人</span>
                        </h3>
                        <ul class="m-pic clearfix">
                            <li>
                                <a href="javascript:;" title="秋冬mua">
                                    <img src="http://p2.music.126.net/rgG1J4gLM0r40_9khvi1yg==/109951166316617864.jpg?param=40y40">
                                </a>
                            </li>
                        </ul>
                        <h3 class="u-hd3">
                            <span class="f-f1">Ta的其他热门专辑</span>
                            <a href="javascript:;" class="more f-ff1">全部></a>
                        </h3>
                        <ul class="m-rct clearfix">
                             <li>
                                 <div class="cver">
                                     <a href="javascript:;" title="Music Of The Spheres">
                                         <img src="http://p2.music.126.net/VGN68yovUJZtC47A_pYISg==/109951166515892030.jpg?param=50y50">
                                     </a>
                                 </div>
                                 <div class="info">
                                     <p class="f-th">
                                     <a href="javascrpit:;" title="Music Of The Spheres" class="f-fs1">
                                         Music Of The Spheres
                                     </a>
                                     </p>
                                     <p class="s-fc3">2021-10-15</p>
                                 </div>
                             </li>
                        </ul>
                     <Load/>
                    </div>
               </div>
          </div>
</template>

<script>
import axios from 'axios';
import Fns from '../components/Fns.vue'
import PageFns from '../components/PageFns.vue'
import CommentArea from '../components/CommentArea.vue'
import Load from '../components/Load.vue'
export default {
        name:'Albumpage',
        data(){
             return {
               introduce:'',
               alliIn:[],
               stretch_flag:false,
               txt:['展开','收起'],
               song:[],
               resource:{
                   album:{
                       artist:{
                           img1v1Url:'',
                           name:''
                       },
                      
                       name:''
                   }
               },
               m_data:{
                   playlist:{
                       subscribedCount:'',
                       shareCount:'',
                       commentCount:''
                   }
               },
               flag_num:-1,

             }
        },
        components:{
            PageFns,
            Fns,
            CommentArea,
            Load
        },
        methods: {
            stretch(){
               this.stretch_flag = !this.stretch_flag
            },
            play1(index) {
                
               this.$bus.$emit('musicList',this.song[index])
            },
            f_show(index){
                this.flag_num = index
            }
        },
      
       
       beforeCreate() {
            axios.get('http://localhost:8080/api/album',{
                 params:{
                     id:this.$route.query.id
                 }
             }).then( (response) => {
                  console.log(response.data);
               this.resource = response.data;
               this.$bus.$emit('shareCount',2332);

                 if (response.data.album.description.length > 160) {
                    this.introduce = response.data.album.description.slice(0,160) + '...'
              }
              this.alliIn = response.data.album.description.split('\n');

               this.song = response.data.songs


             this.$bus.$emit('comment',this.$route.query.id,'/comment/album',3) 
               
             })
             axios.get('http://localhost:8080/api/album/detail/dynamic',{
                 params:{
                      id:this.$route.query.id
                 }
             }).then( (response) => {
                 console.log(response.data);
                 this.m_data.playlist.commentCount  = response.data.commentCount;
                 this.m_data.playlist.shareCount= response.data.shareCount;
                
             })


         
       }, 
        
}
</script>

<style scoped lang='less'>
       .g-mn {
           float: left;
           width: 100%;
           margin-right: -270px;
           text-align: left;

       }
       .g-mnc {
           margin-right:271px ;
       }
       .g-wrap6 {
           padding: 47px 30px 40px 39px;
       }
       .cover {
           float: left;
           position: relative;
           margin:0 -220px 0 0;
           width: 177px;
           height: 177px;
           img {
               display: block;
               width: 100%;
               height: 100%;
           }
           .msk {
               position: absolute;
               width: 209px;
               height: 177px;
               top: 0;
               left: 0;
               background: url(../images/coverall.png) no-repeat 0 -986px;
           }

        }
        .cnt {
            float: right;
            width: 100%;
        }
        .cntc {
            margin-left:230px;
        }
        .topblk {
            margin-bottom: 20px;
        }
        .hd {
            position: relative;
            margin:0 0 12px;
            line-height: 24px;
            h2 {
                line-height: 24px;
                font-size: 20px;
                font-weight: normal;
                text-align: left;
            }

        }
        .ab {
            float: left;
            width: 54px;
            height: 24px;
            background: url(../images/icon.png) no-repeat 0 -186px;

        }
        .tit {
            margin-left:64px;
            position: relative;
        }
        .intr {
            margin-top: 4px;
            line-height: 18px;
            color: #666;
            b {
                display: inline-block;
                font-weight: normal;
            }

        }
        .f-brk {
            word-wrap: break-word;
            word-break: break-word;
           white-space: normal;
        }
        .n-albdesc {
            margin-top: 20px;
            h3 {
                font-size: 12px;
            }
            p {
                color: #666;
                text-indent: 2em;
                line-height: 24px;
                margin-top:4px ;
            }
        }
        .f-fr {
            float: right;
        }
        .u-icn {
            display: inline-block;
            background: url(../images/icon.png) no-repeat;
            width: 11px;
            height: 8px;
            
        }
        .u-icn-6 {
            background-position:-45px -520px;
        }
         .u-icn-7 {
            background-position:-65px -520px;
        }
        .n-songtb {
            margin-top:27px;
            text-align: left;
        }
        .u-title-1 {
            height: 33px;
            border-bottom:2px solid #c20c20;
            h3 {
                float: left;
                font-size: 20px;
                line-height: 28px;
                font-weight: normal;

              }
            .sub {
                margin: 9px 0 0 20px;
                float: left;
            }  
        }
        .m-table {
            width: 100%;
            border: 1px solid #d9d9d9;
            th {
                height: 38px;
                background-color: #f7f7f7;
                color: #666;
                font-weight: normal;
                background: url(../images/table.png) repeat-x 0 0;
            }
            .w1 {
                width: 74px;
                .wp {
                    background: none;
                }
            }
            .wp {
                line-height: 18px;
                padding: 8px 10px;
                height: 18px;
                background: url(../images/table.png) no-repeat 0 -56px;
            }
            .w2 {
                width: 91px;

            }
            .w3 {
             width: 20%;
            }
            .hd1 {
                height: 18px;
                .num {
                    width: 25px;
                    margin-left:5px;
                    color: #999;
                }
               
            }
            td {
                padding: 6px 10px;
                line-height: 18px;
            }
             .ply {
                    float: right;
                    width: 17px;
                    height: 17px;
                    cursor: pointer;
                    background: url(../images/table.png) no-repeat 0 -103px;
                    &:hover {
                        background: url(../images/table.png) no-repeat 0 -128px;
                    }
                }
            .tt {
                float: left;
                width: 100%;
            }
            .ttc {
                height: 18px;
                margin-right:20px;
            }
            .txt {
                position: relative;
                padding-right: 25px;
                margin-right: -25px;
                max-width: 99%;
                height: 20px;
                white-space: nowrap;
            }
            b {
                font-weight: normal;
            }
            .mv {
                position: absolute;
                top: -2px;
                right: 0;
                width: 23px;
                height: 17px;
                margin: 1px 0 0 0;
                background: url(../images/table.png) no-repeat 0 -151px;
                cursor: pointer;
                &:hover {
                    background: url(../images/table.png) no-repeat -30px -151px;
                }
            }
            .text {
                width: 100%;
                position: relative;
            
            }
        }
        table {
            border-collapse: collapse;
            border-spacing: 0;
            table-layout: fixed;
        }
        .opt {
          
            float: left;
            margin-right:-16px ;
        }

        .g-sd {
            position: relative;
            float: right;
            width: 270px;
        }
        .g-wrap1 {
            padding: 20px 40px 40px 30px;
        }
        .u-hd3 {
            position: relative;
            height: 23px;
            margin-bottom: 20px;
            border-bottom:1px solid #ccc;
            color: #333;
        }
        .f-f1 {
            float: left;
            font-size: 12px;
        }
        .m-pic {
            margin-left: -13px;
            padding-bottom:25px;
            li {
                float: left;
                padding: 0 0 13px 13px;
                width: 40px;
                height: 40px;
                img {
                    float: left;
                    width: 40p;
                    height: 40px;
                }
            }
        }
        .more {
            float: right;
            font-weight: normal;
            color: #666;
            font-size: 12px;
        }
        .m-rct {
            margin-bottom: 25px;
            li {
                float: left;
                width: 200px;
                height: 50px;
                margin-bottom:15px;
                line-height: 24px;
            }
        }
        .cver {
            margin-right:-60px;
            float: left;
            width: 50px;
            height: 50px;
            position: relative;
            img {
                display: block;
                width: 100%;
                height: 100%;
            }

        }
        .info {
            margin-left: 60px;
            line-height: 24px;
            p {
                width: 140px;
                text-align: left;
            }
        }
        .f-fs1 {
            font-size: 14px;
            color: #000;
        }
        .int {
            margin-right: 8px;
        }
        
        
</style>